package com.example.databindingdemo;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import com.example.databindingdemo.bean.Book;
import com.example.databindingdemo.databinding.ActivityMainBinding;
import com.example.databindingdemo.listener.EventHandlerListener;
import com.example.databindingdemo.utils.Constants;

public class MainActivity extends AppCompatActivity {
    ActivityMainBinding activityMainBinding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView();
        initListener();
    }

    private void initListener() {
        activityMainBinding.setEventHandler(new EventHandlerListener(this));
    }

    private void initView() {
        activityMainBinding = DataBindingUtil.setContentView(this,R.layout.activity_main);
        Book book = new Book(Constants.title,Constants.content);
        book.rating = Constants.rating;
        activityMainBinding.setBook(book);
    }
}